let fs = require("fs");

let fileHandel = {
    
    createFile: function (fileName, content) {
        fs.writeFileSync(fileName, content);
    },
 
    createRandom: function (maxNum) {
        return (Math.round(Math.random() * maxNum) + 1);
    },

    readFile: function (filePath) {
        let result = fs.readFileSync(filePath);
        return result.toString();
    },
    init: function () {
        
        for (let i = 0; i < 100; i++) {
            let fileName = "./files/" + i + ".txt";
            let num = this.createRandom(1000)
            this.createFile(fileName, num + "");
        }
        let maxNum = 0;
        let name="";
        
        for (let j = 0; j < 100; j++) {
            let fileName = "./files/" + j + ".txt";
            let content = this.readFile(fileName);
            if (maxNum < Number(content)) {
                maxNum = Number(content);
                name = fileName;
            }
        }
        console.log(maxNum,name);
    }
}

fileHandel.init();